// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   DateUtil.java

package com.iphaeton.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.log4j.Logger;

public class DateUtil
{

    public DateUtil()
    {
    }

    public static String dateDisplay(long time)
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date d = new Date(time);
        return format.format(d);
    }

    public static String dateDisplay(Date d)
    {
        if(d != null)
        {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            return format.format(d);
        } else
        {
            return "";
        }
    }

    public static String dateDisplayToYMD(Date d)
    {
        if(d != null)
        {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            return format.format(d);
        } else
        {
            return "";
        }
    }

    public static String dateDisplayToYyyymmdd(Date d)
    {
        if(d != null)
        {
            SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
            return format.format(d);
        } else
        {
            return "";
        }
    }

    public static String dateDisplay()
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(new Date());
    }

    public static String getTime(String key)
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        try {
        	 return String.valueOf(format.parse(key).getTime());
		} catch (ParseException e) {
			 log.info("DateUtil->getTime():" + e.toString());
		}
       
       
       
        return "0";
    }

    public static String getDisplayTime(String key)
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        try {
        	  Date date = new Date(Long.parseLong(key));
              return format.format(date);
		} catch (Exception e) {
			  log.info("DateUtil->getDisplayTime(String key):" + e.toString());
		}
      
      
        return "0";
    }

    public static Date getDate(String key)
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        try {
        	  Date date = format.parse(key);
              return format.parse(key);
		} catch (Exception e) {
			e.printStackTrace();
		        log.info("DateUtil->getDate(String key):" + e.toString());
		}
      
      
       
        return null;
    }

    public static Date getDateAndTime(String key)
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        try {
        	   Date date = format.parse(key);
               return format.parse(key);
		} catch (Exception e) {
			   log.info("DateUtil->getDateAndTime(String key):" + e.toString());
		}
     
     
        return null;
    }

    public static String getTime(long time)
    {
        StringBuffer str = new StringBuffer();
        int hour = (int)time / 0x36ee80;
        int minute = (int)(time % 0x36ee80L) / 60000;
        int second = (int)(time - (long)(hour * 0x36ee80) - (long)(minute * 60000)) / 1000;
        if(hour > 0)
            str.append(hour + "\u5C0F\u65F6:");
        if(minute > 0)
            str.append(minute + "\u5206\u79CD");
        if(second >= 0)
            str.append(second + "\u79D2");
        return str.toString();
    }

    public static Date toDate(long time)
    {
        Date d = new Date();
        d.setTime(time);
        return d;
    }

    public static String getDateByString(String value)
    {
        if(value == null || "".equals(value))
            return value;
        value = value.substring(0, 10);
        String date[] = value.split("/");
        String mm = "";
        String dd = "";
        String yyyy = date[2].trim();
        if(date[0].trim().length() < 2)
            mm = "0" + date[0].trim();
        else
            mm = date[0].trim();
        if(date[1].trim().length() < 2)
            dd = "0" + date[1].trim();
        else
            dd = date[1].trim();
        value = yyyy + "-" + mm + "-" + dd;
        return value;
    }

    public static String getDateString()
    {
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssSSS ");
        return format.format(new Date());
    }

    private static Logger log;
    static Class class$0; /* synthetic field */

    static 
    {
        log = Logger.getLogger(com.iphaeton.common.util.DateUtil.class);
    }
}
